<?php
namespace app\mxty\logic;

use app\mxty\model\Booking as BookingModel;
use app\api\service\User as UserService;
use app\common\enum\order\PayStatus as OrderPayStatusEnum;
use app\common\model\User as UserModel;

class User
{
  public function getUserBooking()
  {
    $userId = UserService::getCurrentLoginUserId();
    $list = BookingModel::getListByUserId($userId);
    return $list;
  }

  public function getUserInfo()
  {
    $user = UserService::getCurrentLoginUser(true);
    return [
      'name' => $user->real_name,
      'mobile' => $user->mobile
    ];
  }

  public function setUserInfo($params) {
    $user = UserService::getCurrentLoginUser(true);
    $user->real_name = $params['name'];
    $user->mobile = $params['mobile'];
    $user->save();
  }

  public function isSetUserInfo()
  {
    $user = UserService::getCurrentLoginUser(true);

    if(!$user->real_name || !$user->mobile) {
      throwError('请填写您的姓名和手机号');
    }
  }
}
